<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_CommonSetting extends TemplateGtkGladeWidgetCompilerBase{

	public function compile( TemplateObj $oObject ){
		A::INSTANCE($oObject,'TemplateGtkGladeWidget');
		$sCompiled=$oObject->getCompiled();// 已编译内容
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);// 窗体变量名称
		if($sEvents=TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('events'))){// 事件 ( 事件要放在构建创建之后，立刻执行 )
			$sEvents=str_replace('GDK_','Gdk::',$sEvents);
			$sCompiled.="\t\t{$sVariableName}->set_events({$sEvents});";
		}
		if($sEvents=TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('extension_events'))){// 扩展事件
			$sEvents=str_replace('GDK_','Gdk::',$sEvents);
			$sCompiled.="\t\t{$sVariableName}->set_extension_events({$sEvents});";
		}
		$nWidthRequest=($nWidthRequest=$oObject->getProperty('width_request'))===null?-1:intval($nWidthRequest);// 请求尺寸
		$nHeightRequest=($nHeightRequest=$oObject->getProperty('height_request'))===null?-1:intval($nHeightRequest);
		if($nWidthRequest>=0 or $nHeightRequest>=0){$sCompiled.="\t\t{$sVariableName}->set_size_request({$nWidthRequest}, {$nHeightRequest});";}
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('visible'))){$sCompiled.="\t\t{$sVariableName}->set_visible(true, false);";}// 可见
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('sensitive'))){$sCompiled.="\t\t{$sVariableName}->set_sensitive(true);$sBrCode";}// 敏感
		if($sTooltip=TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('tooltip'))){// 鼠标悬停提示
			$sComments=($sComments=TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('tooltip','comments')))===null?'':$sComments;
			$sCompiled.="\t\t\$oTip=new GtkTooltips();";
			$sCompiled.="\t\t\$oTip->set_tip({$sVariableName}, \"{$sTooltip}\", \"{$sComments}\");";
		}
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('no_show_all'))){$sCompiled.="\t\t{$sVariableName}->set_no_show_all(true);";}// 不显示全部
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('app_paintable'))){$sCompiled.="\t\t{$sVariableName}->set_app_paintable(true);";}// 可绘制
		$oObject->setCompiled($sCompiled);// 保存编译结果
	}

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor('CommonSetting',__CLASS__);
	}

}
